#ifndef UDPRECEIVER_H
#define UDPRECEIVER_H

#include <QThread>
#include <QUdpSocket>
#include <QObject>

class UdpReceiver : public QThread
{
    Q_OBJECT
public:
    explicit UdpReceiver(QObject *parent = nullptr);
    ~UdpReceiver() override;
    
    void setPort(quint16 port);
    
signals:
    void dataReceived(const QByteArray &data);
    void errorOccurred(const QString &errorString);
    
protected:
    void run() override;
    
private slots:
    void onReadyRead();
    
private:
    QUdpSocket *m_socket;
    quint16 m_port;
};

#endif // UDPRECEIVER_H
